import { defineStore } from 'pinia'
import { ref } from 'vue'
// 仓库都用‘pinia’管理

export const useUserStore = defineStore(
  'big-user',
  () => {
    const token = ref('')
    const setToken = (newToken) => {
      token.value = newToken
    }

    const removeToken = () => {
      token.value = ''
    }

    const userMessage = ref({})
    const setUser = (newUserMessage) => {
      userMessage.value = newUserMessage
    } // 请求获取数据

    return {
      token,
      setToken,
      removeToken,
      userMessage,
      setUser,
    }
  },
  {
    persist: true, // 持久化
  },
)
